﻿using System;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.WindowsLive
{
    /// <summary>
    /// 
    /// </summary>
    public class Tag: ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        public String ID { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public IdName User { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public Double X { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public Double Y { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DateTimeOffset? CreatedTime { get; set; }

       
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsontext"></param>
        public Tag(String jsontext)
        {
            this.SetProperty(jsontext);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsontext"></param>
        public override void SetProperty(String jsontext)
        {
            var d = this.SetData(jsontext);
            this.ID = d.ToString("id");
            this.X = d.ToDouble("x") ?? 0;
            this.Y = d.ToDouble("y") ?? 0;
            if (d.ContainsKey("user"))
            {
                this.User = new IdName(d.ToString("user"));
            }
            this.CreatedTime = d.ToDateTimeOffset("created_time");
        }
    }
}
 